package org.muxiao.seckill.util;

import org.apache.commons.lang3.StringUtils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 验证器工具类
 */
public class ValidatorUtil {

    /**
     * 手机号码正则表达式
     */
    private static final Pattern mobile_pattern = Pattern.compile("^[1][3-9][0-9]{9}$");

    /**
     * 验证手机号码是否合法
     *
     * @param mobile
     * @return
     */
    public static boolean isMobile(String mobile) {
        if (StringUtils.isBlank(mobile)) {
            return false;
        }

        Matcher matcher = mobile_pattern.matcher(mobile);
        return matcher.matches();
    }
}
